﻿using System;

namespace Pansoft.Authority.Entities
{
    /// <summary>权限子项（即软件功能）
    /// </summary>
    public class AuthorityItem : ICloneable
    {
        /// <summary>权限子项的ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>权限名
        /// </summary>
        public string Name { get; set; }

        /// <summary>权限子项的中文描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>该权限子项的功能是否可用
        /// </summary>
        /// <value>
        ///   <c>true</c> 功能可用; <c>false</c> 功能不可用
        /// </value>
        public bool Enable { get; set; }

        /// <summary>数据查询时向上回溯的层级
        /// </summary>
        public short DatasetLevel { get; set; }

        #region ICloneable Members

        public object Clone()
        {
            var item = new AuthorityItem
            {
                Id = Id,
                Name = Name,
                Description = Description,
                Enable = Enable,
                DatasetLevel = DatasetLevel,
            };
            return item;
        }

        #endregion

        public static AuthorityItem Empty
        {
            get
            {
                return new AuthorityItem()
                {
                    Id = 0,
                    Description = string.Empty,
                    Enable = false,
                    DatasetLevel = 0
                };
            }
        }
    }
}